﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;

namespace WebApp3
{
    public partial class frmAdminXggr : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                for (int i = 1; i < 27; i++)
                    ddl_head.Items.Add("头像" + i);
                img_head.ImageUrl = "~\\headimage\\1.gif";
            }
            string chuandiname;
            chuandiname = Session["chuandiname"].ToString();
            this.lblUserName.Text = chuandiname;
        }
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Session["Theme"] == null)
            {
                Page.Theme = "浅蓝色";
            }
            else if (Session["Theme"] == "浅蓝色")
            {
                Page.Theme = "浅蓝色";
            }
            else if (Session["Theme"] == "绿色")
            {
                Page.Theme = "绿色";
            }
            else if (Session["Theme"] == "黄色")
            {
                Page.Theme = "黄色";
            }
            else
            {
                Page.Theme = "红色";
            }
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            string strCn = "server=pc.hstc.cn;database=dhd2014112111;uid=2014112111;pwd=19950511";
            SqlConnection cn = new SqlConnection(strCn);
            try
            {
                cn.Open();
                string sex = Request.QueryString["Sex"];
                if (rbBoy.Checked)
                {
                    sex = "男";
                }
                else
                {
                    sex = "女";
                }

                string strSql = "UPDATE  UserInfo SET           Sex =  N'" + sex + "' ,QqEmail = N'" + txtEmail.Text + "' ,Picture = N'" + (ddl_head.SelectedIndex + 1).ToString() + "'  WHERE   (UserName = N'" + lblUserName.Text + "')";
                SqlCommand cmd = new SqlCommand(strSql, cn);
                int iUpd = cmd.ExecuteNonQuery();
                if (iUpd < 1)
                {
                    this.lblOk.Text = "修改失败！";
                }
                else
                {
                    this.lblOk.Text = "修改成功！";

                }

            }
            catch (Exception ex)
            {

                this.lblOk.Text = ex.Message;
            }
            finally
            {
                cn.Close();
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            img_head.ImageUrl = "~\\headimage\\" + (ddl_head.SelectedIndex + 1) + ".gif";
        }
    }
}